# app/models/family/recipe.py
from tortoise import fields
from app.models.base.base import BaseModel

class Recipe(BaseModel):
    """家庭食谱管理模型"""
    name = fields.CharField(max_length=100, description="食谱名称")
    type = fields.CharField(max_length=20, description="菜系类型")  # sichuan, cantonese, shandong, jiangsu, zhejiang, fujian, hunan, anhui
    difficulty = fields.IntField(description="难度等级 1-简单 2-中等 3-困难")
    cooking_time = fields.IntField(description="制作时间(分钟)")
    servings = fields.IntField(description="适合人数")
    ingredients = fields.TextField(null=True, description="食材清单")
    instructions = fields.TextField(null=True, description="制作步骤")
    tips = fields.TextField(null=True, description="小贴士")
    
    # 关联字段
    user = fields.ForeignKeyField('models.User', related_name='recipes')
    family = fields.ForeignKeyField('models.Family', related_name='recipes')
    
    class Meta:
        table = "family_recipes"
        table_description = "家庭食谱管理表"